package lleida.festamajor.activities;

import lleida.festamajor.R;
import lleida.festamajor.controllers.EventController;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.ImageView;

public class AEventDetail extends FMActivity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.event);
		
		fillData();
	}
	
	protected void fillData() {
		((TextView) findViewById(R.id.event_title)).setText(EventController.getSelectedEventName());
		((TextView) findViewById(R.id.event_place)).setText(EventController.getSelectedEventPlace());
		((TextView) findViewById(R.id.event_time)).setText(EventController.getSelectedEventDate() + " " + EventController.getSelectedEventTime());
		((TextView) findViewById(R.id.event_description)).setText(EventController.getSelectedEventDescription());
		switch (EventController.getSelectedEventCategoryIcon()) {
		case 0:
			((ImageView) findViewById(R.id.event_category)).setImageResource(R.drawable.cultura);
			break;
		case 1:
			((ImageView) findViewById(R.id.event_category)).setImageResource(R.drawable.esport);
			break;
		case 2:
			((ImageView) findViewById(R.id.event_category)).setImageResource(R.drawable.musica);
			break;
		case 3:
			((ImageView) findViewById(R.id.event_category)).setImageResource(R.drawable.teatre);
			break;
		case 4:
			((ImageView) findViewById(R.id.event_category)).setImageResource(R.drawable.infantil);
			break;
		case 5:
			((ImageView) findViewById(R.id.event_category)).setImageResource(R.drawable.institucio);
			break;
		case 6:
			((ImageView) findViewById(R.id.event_category)).setImageResource(R.drawable.tecno);
			break;
		case 7:
			((ImageView) findViewById(R.id.event_category)).setImageResource(R.drawable.museu);
			break;
		}
	}
	
	public void onClickListener(View v) {
		switch (v.getId()) {
		case R.id.event_previous:
			EventController.setSelectedPrevious();
			fillData();
			break;
		case R.id.event_list:
			finish();
			break;
		case R.id.event_map:
			EventController.setSelectedPlace();
			app.showPlace();
			break;
		case R.id.event_next:
			EventController.setSelectedNext();
			fillData();
			break;
		}
	}
	
	public void onBackPressed() {
		finish();
	}
}
